The technology described herein relates to graphics processing, and in particular to the operation of graphics processing pipelines that include a vertex shading stage.
As is known in the art, graphics processing is normally carried out by first splitting a scene (e.g. a 3-D model) to be displayed into a number of similar basic components or “primitives”, which primitives are then subjected to the desired graphics processing operations. The graphics “primitives” are usually in the form of simple polygons, such as triangles.
The primitives for an output such as a frame to be displayed are usually generated by the applications program interface for the graphics processing system, using the graphics drawing instructions (requests) received from the application (e.g. game) that requires the graphics processing.
Each primitive is usually defined by and represented as a set of vertices. Each vertex for a primitive typically has associated with it a set of “attributes”, i.e. a set of data values for the vertex. These attributes will typically include position data and other, non-position data (varyings), e.g. defining colour, light, normal, texture coordinates, etc., for the vertex in question.
For a given output, e.g. frame to be displayed, to be generated by the graphics processing system, there will typically be a set of vertices defined for the output in question. The primitives to be processed for the output will then be indicated as comprising given vertices in the set of vertices for the graphics processing output being generated. Typically, the overall output, e.g. frame to be generated, will be divided into smaller units of processing, referred to as “draw calls”. Each draw call will have a respective set of vertices defined for it and a set of primitives that use those vertices.
Once primitives and their vertices have been generated and defined, they can be processed by the graphics processing system, in order to generate the desired graphics processing output (render target), such as a frame for display. This basically involves rasterising and rendering the primitives to generate the graphics processing output.
The rasterising and rendering processes use the vertex attributes associated with the vertices of the primitives that are being processed. To facilitate this operation, the attributes of the vertices defined for the given graphics processing output (e.g. draw call) are usually subjected to an initial so-called “vertex shading” operation, before the primitives are rasterised and rendered. This “vertex shading” operation operates to transform the attributes for each vertex into a desired form for the subsequent graphics processing operations. This may comprise, for example, transforming vertex position attributes from the world or user space that they are initially defined for to the screen space that the output of the graphics processing system is to be displayed in.
A graphics processing pipeline will typically therefore include a vertex shading stage (a vertex shader) that executes vertex shading computations on the initial vertex attribute values defined for the vertices so as to generate a desired set of output vertex attributes (i.e. appropriately “shaded” attributes) for use in subsequent processing stages of the graphics processing pipeline.
The vertex shader is typically a programmable processing stage of the graphics processing pipeline that executes vertex shader programs (“vertex shaders”) on input vertex attribute values to generate a desired set of output “vertex shaded” attributes data (e.g. appropriately transformed vertex position data) for processing by the rest of the graphics processing pipeline. The vertex shader may share programmable processing circuitry with other “shaders” of the graphics processing pipeline, or it may be a distinct programmable processing unit.
The vertex shader is thus a processing unit that performs graphics processing by running small programs for each vertex (and for each vertex attribute) in a graphics output (render target) to be generated (such as a frame). Typically an execution thread will be issued for each vertex (and/or vertex attribute) to be processed, and the thread will then execute the instructions in the shader program to produce the desired vertex shaded output attributes data.
Once the vertex attributes have been shaded, the “shaded” attributes are then used when processing the vertices (and the primitives to which they relate) in the remainder of the graphics processing pipeline.
(In general “input variables” and “output variables” are the generic terms used for inputs and outputs from shaders (shading stages) in graphics processing pipelines. Before being vertex shaded, a vertex is a collection of “generic vertex attributes” that can be accessed within the vertex shader as input variables. The vertex shader execution then produces a vertex position and any outputs explicitly written by the vertex shader. “Varyings” are the attributes communicated from the vertex shader to rasterisation and fragment shading, not including position. (Thus only the non-position outputs from the vertex shader are “varyings”.))
FIG. 1 shows schematically the above operation in the case of an exemplary tile based graphics processing pipeline 10.
(As the graphics processing pipeline shown in FIG. 1 is a tile based rendering pipeline, the two-dimensional render output or target (i.e. the output of the rendering process, such as an output frame to be displayed) is rendered as a plurality of smaller area sub-regions, usually referred to as “tiles”. The tiles are each rendered separately (typically one after another). The rendered tiles are then combined to provide the complete rendering output (e.g. frame for display). In such arrangements, the render target (output) is typically divided (by area) into regularly-sized and shaped rendering tiles (they are usually e.g., squares or rectangles) but this is not essential.
Other terms that are commonly used for “tiling” and “tile-based” rendering include “chunking” (the rendering tiles are referred to as “chunks”) and “bucket” rendering. The terms “tile” and “tiling” will be used hereinafter for convenience, but it should be understood that these terms are intended to encompass all alternative and equivalent terms and techniques.)
FIG. 1 shows some but not all of the stages and components of the overall graphics processing pipeline, namely the stages that are relevant to the operation of the technology described herein. FIG. 1 thus shows a vertex shading stage 11, a tiler 12 and a fragment frontend and fragment shader stage 13 of the graphics processing pipeline 10.
The vertex shading stage 11 receives incoming vertices (attributes data) and performs vertex shading operations on the vertex attributes, such as transforming the attributes of the vertices using a transformation function.
The vertex-shaded attributes, together with a list of primitives that make up the, e.g. draw call being processed, are then passed to a tiler 12 that sorts the primitives into respective primitive lists (tile lists) for the tiles that the graphics processing output (render target) has been divided into, to indicate the primitives to be processed for each tile.
The primitive lists, together with the vertex shaded attributes, are then fed to the fragment frontend and fragment shader stage 13. The fragment frontend and fragment shader stage 13 performs the rasterising and rendering processes.
To do this it includes a fixed hardware element that performs fragment “front-end” operations including primitive (e.g. triangle) setup and rasterisation. The rasterisation process, as is known in the art, rasterises the primitives to generate “fragments” on which the further graphics processing operations, including rendering, are to be carried out. (The “fragments” are the graphical entities that pass through the rendering process (the rendering pipeline).)
The fragments produced by the rasteriser are rendered in the fragment shader of the fragment frontend and fragment shader stage 13. The rendering process uses the fragment positions (derived from the shaded vertex position attributes) together with the shaded vertex varyings (non-position vertex attributes) to derive data, such as red, green and blue (RGB) colour values and an “Alpha” (transparency) value, necessary to represent the primitives at the sampling positions of the render target (i.e. the fragment shader “shades” the sample positions of the render target).
The rendered fragment data (sampling position data) is written to a tile buffer and, subsequently, written out as pixel data to a frame buffer, e.g. for display (this may include backend fragment operations, such as downsampling, to determine the final pixel colours to be stored in the frame buffer).
The Applicants believe that there remains scope for improvements for graphics processing pipelines that include a vertex shading stage.
Like reference numerals are used for like features throughout the drawings, where appropriate.